//
//  CAUserInfoView.m
//  LNH
//
//  Created by twentylx on 2018/2/26.
//  Copyright © 2018年 twentylx. All rights reserved.
//

#import "CAUserInfoView.h"

@implementation CAUserInfoView

/**
 为视图绑定 viewModel
 
 @param viewModel 要绑定的ViewModel
 @param params 额外参数
 */
- (void)bindViewModel:(id <LMViewProtocol>)viewModel withParams:(NSDictionary *)params {
    
}

/**
 初始化额外数据
 */
- (void)lm_initializeForView {
    self.backgroundColor = [UIColor whiteColor];
}

/**
 初始化视图
 */
- (void)lm_createViewForView {
    [self setNeedsUpdateConstraints];
    
    [self addSubview:self.titleView];
    [self.titleView addSubview:self.titleLabel];
    
    [self addSubview:self.nameTextField];
    [self addSubview:self.lineView];
    [self addSubview:self.phoneTextField];
    [self addSubview:self.line1View];
    [self addSubview:self.cidTextField];
    [self addSubview:self.line2View];
    [self addSubview:self.wechatTextField];
    [self addSubview:self.line3View];
}

#pragma mark layout
- (void)updateConstraints {
    [super updateConstraints];
    
    [_titleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self);
        make.height.mas_equalTo(40);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleView).offset(20);
        make.centerY.equalTo(self.titleView);
    }];
    
    [_nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.titleView.mas_bottom);
        make.height.mas_equalTo(44);
    }];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.nameTextField.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_phoneTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.nameTextField.mas_bottom);
        make.height.mas_equalTo(44);
    }];
    
    [_line1View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.phoneTextField.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_cidTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.phoneTextField.mas_bottom);
        make.height.mas_equalTo(44);
    }];
    
    [_line2View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.cidTextField.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
    
    [_wechatTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.cidTextField.mas_bottom);
        make.height.mas_equalTo(44);
    }];
    
    [_line3View mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.and.right.equalTo(self);
        make.top.equalTo(self.wechatTextField.mas_bottom);
        make.height.mas_equalTo(ONE_PIXEL);
    }];
}

#pragma mark get & set
- (UIView *)titleView {
    if (!_titleView) {
        _titleView = [UIView new];
        _titleView.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _titleView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.text = @"请填写个人资料";
        _titleLabel.font = [UIFont systemFontOfSize:16];
    }
    return _titleLabel;
}

- (UITextField *)nameTextField {
    if (!_nameTextField) {
        _nameTextField = [UITextField new];
        _nameTextField.placeholder = @"真实姓名";
        _nameTextField.font = [UIFont systemFontOfSize:16];
        _nameTextField.backgroundColor = [UIColor whiteColor];
        
        UIView *leftView = [[UIView alloc] initWithFrame:(CGRect){0, 0, 20, 20}];
        _nameTextField.leftView = leftView;
        _nameTextField.leftViewMode = UITextFieldViewModeAlways;
    }
    return _nameTextField;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _lineView;
}

- (UITextField *)phoneTextField {
    if (!_phoneTextField) {
        _phoneTextField = [UITextField new];
        _phoneTextField.placeholder = @"电话号码";
        _phoneTextField.font = [UIFont systemFontOfSize:16];
        _phoneTextField.backgroundColor = [UIColor whiteColor];
        
        UIView *leftView = [[UIView alloc] initWithFrame:(CGRect){0, 0, 20, 20}];
        _phoneTextField.leftView = leftView;
        _phoneTextField.leftViewMode = UITextFieldViewModeAlways;
    }
    return _phoneTextField;
}

- (UIView *)line1View {
    if (!_line1View) {
        _line1View = [UIView new];
        _line1View.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _line1View;
}

- (UITextField *)cidTextField {
    if (!_cidTextField) {
        _cidTextField = [UITextField new];
        _cidTextField.placeholder = @"身份证号";
        _cidTextField.font = [UIFont systemFontOfSize:16];
        _cidTextField.backgroundColor = [UIColor whiteColor];
        
        UIView *leftView = [[UIView alloc] initWithFrame:(CGRect){0, 0, 20, 20}];
        _cidTextField.leftView = leftView;
        _cidTextField.leftViewMode = UITextFieldViewModeAlways;
    }
    return _cidTextField;
}

- (UIView *)line2View {
    if (!_line2View) {
        _line2View = [UIView new];
        _line2View.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _line2View;
}

- (UITextField *)wechatTextField {
    if (!_wechatTextField) {
        _wechatTextField = [UITextField new];
        _wechatTextField.placeholder = @"微信号";
        _wechatTextField.font = [UIFont systemFontOfSize:16];
        _wechatTextField.backgroundColor = [UIColor whiteColor];
        
        UIView *leftView = [[UIView alloc] initWithFrame:(CGRect){0, 0, 20, 20}];
        _wechatTextField.leftView = leftView;
        _wechatTextField.leftViewMode = UITextFieldViewModeAlways;
    }
    return _wechatTextField;
}

- (UIView *)line3View {
    if (!_line3View) {
        _line3View = [UIView new];
        _line3View.backgroundColor = RGBCOLOR(241, 241, 241);
    }
    return _line3View;
}


@end
